Event.observe(window, 'load', function () {
    Sortable.create('sort', {
        tag: 'div',
        only: 'left_box',
        handle: 'draggable_header',
        dropOnEmpty: true,
        constraint: false,
        onUpdate: function () {
            new Ajax.Request('index.php', {
                parameters: {
                    sort: Sortable.serialize('sort')
                }
            })
        }
    })
});

function loadPage(page) {
    $("content-mid").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Updater('content-mid', page, {
        method: 'get',
        evalScripts: false,
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("content-mid").innerHTML = response
        }
    })
}

function submitHead() {
    var habbo = $("habbo").value;
    var hotel = $("hotel").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/head/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            hotel: hotel
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitFont() {
    var text = $("text").value;
    var font = $("font").value;
    var space = $("space").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/font/result.php', {
        method: 'post',
        parameters: {
            text: text,
            font: font,
            space: space
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitThrone() {
    var habbo = $("habbo").value;
    var country = $("country").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/throne/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            country: country
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitFact() {
    var name = $("name").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/fact/result.php', {
        method: 'post',
        parameters: {
            name: name
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitKiss() {
    var habbo1 = $("habbo1").value;
    var habbo2 = $("habbo2").value;
    var country = $("country").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/kiss/result.php', {
        method: 'post',
        parameters: {
            habbo1: habbo1,
            habbo2: habbo2,
            country: country
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitAvatar() {
    var name = $("name").value;
    var country = $("country").value;
    var bg = $("bg").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/avatar/result.php', {
        method: 'post',
        parameters: {
            name: name,
            country: country,
            bg: bg
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitVolter() {
    var text = $("text").value;
    var size = $("size").value;
    var width = $("width").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('resources/usables/volter/result.php', {
        method: 'post',
        parameters: {
            text: text,
            size: size,
            width: width,
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitSupport() {
    var habbo = $("habbo").value;
    var email = $("email").value;
    var resource = $("resource").value;
    var problem = $("problem").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('content/support/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            email: email,
            resource: resource,
            problem: problem,
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitScript() {
    var habbo = $("habbo").value;
    var email = $("email").value;
    var link = $("link").value;
    var comment = $("comment").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('content/submit/script/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            email: email,
            link: link,
            comment: comment,
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitLayout() {
    var habbo = $("habbo").value;
    var email = $("email").value;
    var link = $("link").value;
    var comment = $("comment").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('content/submit/layout/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            email: email,
            link: link,
            comment: comment,
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitGuide() {
    var habbo = $("habbo").value;
    var email = $("email").value;
    var link = $("link").value;
    var comment = $("comment").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('content/submit/guide/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            email: email,
            link: link,
            comment: comment,
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}

function submitTutorial() {
    var habbo = $("habbo").value;
    var email = $("email").value;
    var link = $("link").value;
    var comment = $("comment").value;
    $("result").innerHTML = "<center><img src=\"images/load.png\"></center>";
    new Ajax.Request('content/submit/tutorial/result.php', {
        method: 'post',
        parameters: {
            habbo: habbo,
            email: email,
            link: link,
            comment: comment,
        },
        onSuccess: function (transport) {
            var response = transport.responseText || "Loading..";
            $("result").innerHTML = response
        }
    })
}
